﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace DAL
{
    /// <summary>
    /// Author: Sissi Zeng
    /// Date:2012 08-08 16:35
    /// Read and Write from/into Table Level
    /// </summary>
    public class Level
    {

        /// <summary>
        /// Construtor
        /// </summary>
        public Level()
        {

        }

        /// <summary>
        /// select a certain column from table Level in database
        /// </summary>
        /// <param name="column">column name</param>
        /// <returns>Result in DataReader</returns>
        public SqlDataReader getListBy(string column)
        {
            string sqlStr = "select " + column + " from Level";
            using (SqlDataReader dr = SQLHelper.ExcuteReader(SQLHelper.ConnectionStringProjectb, CommandType.Text, sqlStr, null))
            {
                return dr;

            }

        }

        /// <summary>
        /// select all column from table level in database
        /// </summary>
        /// <returns>Resultset in DataSet</returns>
        public DataSet getAll()
        {

            DataSet ds = new DataSet();
            using (SqlConnection conn = new SqlConnection(SQLHelper.ConnectionStringProjectb))
            {
                conn.Open();
                string selectStatement = "select * from Level";
                SqlDataAdapter da = new SqlDataAdapter(selectStatement, conn);

                da.Fill(ds, "LevelList");

            }
            return ds;
        }
    }
}
